<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">

	function selectAll() {
		$.ajax({
			url : "book/books",
			type : "get",
			dataType : "json",
			success : function(result) {
				//alert(result)
				
				 $(result).each(
						function (i, values) {
	                        $("#booklist").append(
	                            "<tr><td>"+values.bid+"</td>"
	                            +"<td>"+values.bname+"</td>"
	                            +"<td>"+values.count+"</td>"
	                            +"<td>"+values.author+"</td>"
	                            +"<td>"+values.outdate+"</td>"
	                            +"<td>"+values.price+"</td>"
	                            +"<td>"+values.output+"</td>"
	                            +"<td>"+values.description+"</td>"
	                            +"<td>"+values.flag+"</td>"
								+"<td><a href='update.jsp?bid="+values.bid+"'>修改</a></td>"
								+"<td><a href='javascript:del("+values.bid+")'>删除</a></td></tr>"
								
								
						)
					}
				);
		
		}
	});
					
	}
	$(function() {
		selectAll();
	})
	  function del(bid){
		  
		  var fbid=bid;
		  
		  alert(fbid);
		  $.ajax({
				url:"book/delete",
				type:"post",
				data:{
					"bid":fbid,
				},
				success:function(result){
					alert(result);
					//selectAll();
					window.location.reload();
				} 
	  });
	}
</script>
<title>Insert title here</title>
</head>
<body>
	
	
	<table class="table table-bordered table-hover table-condensed">
		<thead>
			<tr>
			<th><a href="add.jsp">增加书籍</a></th>
			</tr>
			<tr>
				<th>书籍编号</th>
				<th>书名</th>
				<th>数量</th>
				<th>作者</th>
				<th>出版时间</th>
				<th>价格</th>
				<th>出版社</th>
				<th>描述</th>
				<th>状态</th>
				<th>操作</th>
				
			</tr>
		</thead>
		<tbody id="booklist"></tbody>
	</table>
	
</body>
</html>